<extend name="../Public/base" />
<block name="title">编辑模块</block>
<block name="body">
    <form class="form form-horizontal form-validate" id="form-ajax-Form" method="post">
        <input type="hidden" name="parent_id" value="{$parent_id}" />
        <table class="table table-border table-bordered table-bg">
            <thead>
                <tr class="text-c">
                    <th width="25%">菜单名称</th>
                    <th width="15%">应用名称</th>
                    <th width="15%">控制器名称</th>
                    <th width="15%">方法名称</th>
                    <th width="10%">排序</th>
                    <th width="10%">是否显示</th>
                    <th width="10%">操作</th>
                </tr>
            </thead>
            <tbody id="action_list">
            <foreach name="menus" item="var">
                <eq name="var.parent_id" value="$parent_id">
                    <tr>
                        <td><input type="text" class="input-text" name="oldlines[{$var.menu_id}][menu_name]" value="{$var.menu_name}"/></td>
                        <td><input type="text" class="input-text" name="oldlines[{$var.menu_id}][app]" value="{$var.app}" /></td>
                        <td><input type="text" class="input-text" name="oldlines[{$var.menu_id}][controller]" value="{$var.controller}" /></td>
                        <td><input type="text" class="input-text" name="oldlines[{$var.menu_id}][action]" value="{$var.action}" /></td>
                        <td><input type="text" class="input-text" name="oldlines[{$var.menu_id}][sort]" value="{$var.sort}" /></td>
                        <td>
                            <select class="select" name="oldlines[{$var.menu_id}][status]">
                                <option value="0" <eq name="var.status" value="0">selected="selected"</eq> >隐藏</option>
                                <option value="1" <eq name="var.status" value="1">selected="selected"</eq> >显示</option>
                            </select>
                        </td>
                        <td class="text-c">
                            <a title="删除" href="javascript:;" class="btn btn-danger radius" onclick="del('{$var['menu_id']}','menu_id')" class="ml-5">
                                删除
                            </a>
                        </td>
                    </tr>
                </eq>
            </foreach>
            </tbody>
        </table>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;确认&nbsp;&nbsp;">
                <a href="javascript:void(0);" class="btn btn-primary radius" id="action_add">&nbsp;&nbsp;新增一行&nbsp;&nbsp;</a>

            </div>
        </div>
    </form>
</block>
<block name="js">
<script>
    $(document).ready(function (e) {
        var num = 0;
        $("#action_add").click(function () {
            num++;
            var html = '<tr id="action_' + num + '">' +
                    '<td><input type="text" name="newlines[' + num + '][menu_name]" class="input-text"/></td>' +
                    '<td><input type="text" name="newlines[' + num + '][app]" class="input-text" /></td>' +
                    '<td><input type="text" name="newlines[' + num + '][controller]" class="input-text" /></td>' +
                    '<td><input type="text" name="newlines[' + num + '][action]" class="input-text" /></td>' +
                    '<td><input type="text" name="newlines[' + num + '][sort]" value="100" class="input-text" /></td>' +
                    '<td><select class="select" name="newlines[' + num + '][status]"><option value="0">隐藏</option><option value="1">显示</option></select></td>' +
                    '<td class="text-c"><a href="javascript:void(0);" onclick="$(\'#action_' + num + '\').remove();" class="btn btn-danger radius" >移除</a></td>' +
                    '</tr>';
            $("#action_list").append(html);
        });
    });
</script>
</block>